// import { reqSearchPage } from '@/api'

// const state = {
//   searchData: {}
// }

// const mutations = {
//   SET_SEARCHDATA(state, searchData) {
//     state.searchData = searchData
//   }
// }

// const actions = {
//   async getSearchData({ commit }, params) {
//     try {
//       let result = await reqSearchPage(params)
//       commit('SET_SEARCHDATA',result.data)
//     } catch (error) {
//       console.error(error);
//     }
//   }
// }

// const getters = {}

// export default {
//   namespaced: true,
//   state,
//   mutations,
//   actions,
//   getters,
// }

import { reqSearchPage } from '@/api'

const state = {
  searchData: {}
}

const mutations = {
  SET_SEARCHDATA(state,searchData) {
    state.searchData = searchData
  }
}

const actions = {
  async getSearchData({ commit }, searchParams) {
    if (searchParams.pageNo != searchParams.recordPageNo)

    searchParams.pageNo = 1

    searchParams.recordPageNo = undefined


    try {
      let result = await reqSearchPage(searchParams)
      commit('SET_SEARCHDATA',result.data)
    } catch (error) {
      console.error(error)
    }
  }

}
const getters = {
  attrsList(state) {
    return state.searchData.attrsList || []
  },
  goodsList(state) {
    return state.searchData.goodsList || []
  },
  tmList(state) {
    return state.searchData.trademarkList || []
  },
  total(state) {
    return state.searchData.total || 0
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters,
}